<?

/***************************************************************************
 Jupiter Content System @ Jupiterportal.com
 Copyright (C) 2005 Cosmin Flavius (highstrike@gmail.com)

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 More Info About The Licence At http://www.gnu.org/copyleft/gpl.html
****************************************************************************/
/*
<?= ($language['Staff Admin Title']) ?>
Graphix-Tavern Development Team
All support/bugs/issues please report them @ http://www.graphix-tavern.com.
*/
//-----------------------------------------------------------------
//  Filter Acces Rightes
//-----------------------------------------------------------------

switch($a)
{
case 1:
if(isset($is_guest) || isset($is_user) || isset($is_moderator))
{header("location: $PHP_SELF?i=2"); exit; }

		//-----------------------------------------------------------------
		//  BBcode check
		//-----------------------------------------------------------------

		for ($i = 1; $i <= 5; $i++)
		{
			if(check_tag_order($editstaffintrests) == $i) { header("location: $PHP_SELF?n=modules/staff&i=9$i"); exit; }
			if(check_tag_order($editstaffprograms) == $i) { header("location: $PHP_SELF?n=modules/staff&i=9$i"); exit; }
			if(check_tag_order($editstaffprogramming) == $i) { header("location: $PHP_SELF?n=modules/staff&i=9$i"); exit; }
			if(check_tag_order($editstaffresources) == $i) { header("location: $PHP_SELF?n=modules/staff&i=9$i"); exit; }
			if(check_tag_order($editstaffwtgb) == $i) { header("location: $PHP_SELF?n=modules/staff&i=9$i"); exit; }
			if(check_tag_order($editstaffcomments) == $i) { header("location: $PHP_SELF?n=modules/staff&i=9$i"); exit; }
		}
		
		
		//-----------------------------------------------------------------
		//  Take care of some things
		//-----------------------------------------------------------------

		$editstaffintrests = jcm_linebreaks(trim(jcm_stripslashes($editstaffintrests)));
		$editstaffprograms = jcm_linebreaks(trim(jcm_stripslashes($editstaffprograms)));
		$editstaffprogramming = jcm_linebreaks(trim(jcm_stripslashes($editstaffprogramming)));
		$editstaffresources = jcm_linebreaks(trim(jcm_stripslashes($editstaffresources)));
		$editstaffwtgb = jcm_linebreaks(trim(jcm_stripslashes($editstaffwtgb)));
		$editstaffcomments = jcm_linebreaks(trim(jcm_stripslashes($editstaffcomments)));
		if($overflow = check_tag_order($editstaffintrests)) $editstaffintrests = substr($editstaffintrests, 0, $overflow[0]).substr($editstaffintrests, $overflow[1], (strlen($editstaffintrests) - $overflow[0]));
		if($overflow = check_tag_order($editstaffprograms)) $editstaffprograms = substr($editstaffprograms, 0, $overflow[0]).substr($editstaffprograms, $overflow[1], (strlen($editstaffprograms) - $overflow[0]));
		if($overflow = check_tag_order($editstaffprogramming)) $editstaffprogramming = substr($editstaffprogramming, 0, $overflow[0]).substr($editstaffprogramming, $overflow[1], (strlen($editstaffprogramming) - $overflow[0]));
		if($overflow = check_tag_order($editstaffresources)) $editstaffresources = substr($editstaffresources, 0, $overflow[0]).substr($editstaffresources, $overflow[1], (strlen($editstaffresources) - $overflow[0]));
		if($overflow = check_tag_order($editstaffwtgb)) $editstaffwtgb = substr($editstaffwtgb, 0, $overflow[0]).substr($editstaffwtgb, $overflow[1], (strlen($editstaffwtgb) - $overflow[0]));
		if($overflow = check_tag_order($editstaffcomments)) $editstaffcomments = substr($editstaffcomments, 0, $overflow[0]).substr($editstaffcomments, $overflow[1], (strlen($editstaffcomments) - $overflow[0]));



		//-----------------------------------------------------------------
		//  Begin writing the information
		//-----------------------------------------------------------------
		$edit['username'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffusername));
		$edit['rank'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffrank));
		$edit['email'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffemail));
		$edit['age'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffage));
		$edit['bday'] = $editstaffbday;
		$edit['live'] = jcm_htmlspecialchars(jcm_stripslashes($editstafflive));
		$edit['intrests'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffintrests));
		$edit['programs'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffprograms));
		$edit['programming'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffprogramming));
		$edit['howlong'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffhowlong));
		$edit['music'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffmusic));
		$edit['resources'] = $editstaffresources;
		$edit['wtgb'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffwtgb));
		$edit['comments'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffcomments));
		$edit['active'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffactive));
		$db->updateRow("staff",$edit,"id= '$d'");
		header("location: $PHP_SELF?n=modules/staff");

	break;

case 2:
	//-----------------------------------------------------------------
	//  Load the staff's row + Check for existance
	//-----------------------------------------------------------------

		$staff = $db->getLine("SELECT * FROM staff",$d);
		if(!$staff) header("location: $PHP_SELF?i=error");

?>
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='head'>
   <td class='head' colspan='2' align='center'><?= ($language['Staff Overlook']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['General Information']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

	<tr>
	<td width="20%" class="con1">Staffs Name:</td> 
        <td class="con1"><?= ($staff['username']) ?></td></tr>
	<tr><td width="20%" class="con1">Staffs Rank:</td> 
        <td class="con1"><?= ($staff['rank']) ?></td></tr>
	<tr><td width="20%" class="con1">Rank Details:</td>
	<? $desc = $db->getLine("SELECT * FROM staff_positions WHERE rank='$staff[rank]'"); ?>
       <td class="con1"> <?= ($desc['description']) ?></td></tr>
</table></table>

<br />

<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Personal Information']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

	<tr>
	<td width="20%" class="con1">Email:</td> 
        <td class="con1"><? if($staff['email'] == NULL) { echo"N/A"; } else { ?> <a href="mailto:<?= ($staff['email']) ?>">Email this staff member</a><? } ?></td></tr>
	<tr><td width="20%" class="con1">Current age:</td> 
        <td class="con1"><? if($staff['age'] == NULL) { echo"N/A"; } else { ?> <?= ($staff['age']) ?> <? } ?></td></tr>
	<tr><td width="20%" class="con1">Birthday:</td> 
        <td class="con1"><? if ($staff['bday'] == NULL) { echo"N/A"; } else { ?><?= ($staff['bday']) ?>  <? } ?></td></tr>
	<tr><td width="20%" class="con1">Where do I live:</td> 
        <td class="con1"><? if ($staff['live'] == NULL) { echo"N/A"; } else { ?><?= ($staff['live']) ?>  <? } ?></td></tr>
	<tr><td width="20%" class="con1">My interests:</td> 
        <td class="con1"><? if ($staff['intrests'] == NULL) { echo"N/A"; } else { ?> <?= parse_message($staff['intrests']) ?> <? } ?></td></tr>
	<tr><td width="20%" class="con1">Programs I user:</td> 
        <td class="con1"><? if ($staff['programs'] == NULL) { echo"N/A"; } else { ?> <?= parse_message($staff['programs']) ?> <? } ?></td></tr>
	<tr><td width="20%" class="con1">Programming languages I know:</td> 
        <td class="con1"><? if($staff['programming'] == NULL) { echo"N/A"; } else { ?> <?= parse_message($staff['programming']) ?> <? } ?></td></tr>
	<tr><td width="20%" class="con1">How long have I been doing this:</td> 
        <td class="con1"><? if($staff['howlong'] == NULL) { echo"N/A"; } else { ?> <?= ($staff['howlong']) ?> <? } ?></td></tr>
	<tr><td width="20%" class="con1">My music genere:</td> 
        <td class="con1"><? if($staff['music'] == NULL) { echo"N/A"; } else { ?><?= ($staff['music']) ?> <? } ?></td></tr>
	<tr><td width="20%" class="con1">Resource sites I use:</td> 
        <td class="con1"><? if($staff['resources'] == NULL) { echo"N/A"; } else { ?><?= parse_message($staff['resources']) ?> <? } ?></td></tr>
	<tr><td width="20%" class="con1">Words to go by:</td> 
        <td class="con1"><? if($staff['wtgb'] == NULL) { echo"N/A"; } else { ?><?= parse_message($staff['wtgb']) ?> <? } ?></td></tr>
	<tr><td width="20%" class="con1">Personal comments:</td> 
        <td class="con1"><? if($staff['comments'] == NULL) { echo"N/A"; } else { ?><?= parse_message($staff['comments']) ?> <? } ?></td></tr>
</table></table>

<br />
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Misc Information']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

	<tr>
	<td width="20%" class="con1">Active:</td> 
        <td class="con1"><? if($staff['active'] == 0) { echo"This staff members status is currently set to inactive."; } else { echo"This staff members status is currently set to active."; } ?></a></td></tr>
</table></table>
<br />

<br />
<?
	if(isset($is_guest) || isset($is_administrator) || isset($is_webmaster)) {
}
else
{
 $user = $db->getLine("SELECT * FROM users WHERE id='{$_SESSION['id']}' AND username='{$_SESSION['username']}'");
 if($staff['username'] == ($user['username'])) {
?>
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Management Controls']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

	<tr>
<?
        echo"<td class='con1'><div align='center'><a href='$PHP_SELF?n=modules/staff&a=18&d={$staff['id']}'> Manage Staff </a></div></td></tr>";
?>
</table></table>
<br />
<?
}
else
{
}
}
if (isset($is_webmaster) || isset($is_administrator)) {
?>
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Management Controls']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

	<tr>
<?
        echo"<td class='con1'><div align='center'><a href='$PHP_SELF?n=modules/staff&a=5&d={$staff['id']}'> Manage Staff </a> &nbsp;&nbsp; <a href='$PHP_SELF?n=modules/staff&a=17&d={$staff['id']}'> Delete Staff </a></div></td></tr>";
?>
</table></table>
<br />
<?
}
else
{
}
?>
<? echo"<a href='$PHP_SELF?n=modules/staff'><center>{$language['Back']}</center></a>"; ?>
</tr>
</table>
<br />
<?
	break;

default:

		//-----------------------------------------------------------------
		//  Sorting Stuff
		//-----------------------------------------------------------------

		if(!isset($s)) $s = 'id'; // Default value
		if(!isset($t)) $t = 'ASC'; // Default value

		$sname1 = "id";
		$sname2 = "username";
		$sname3 = "rank";
		$sname4 = "active";


		if($t == "ASC"){ $t = "DESC"; $t2 = "ASC"; }
		else{ $t = "ASC"; $t2 = "DESC"; }

		if($t == "ASC"){ $t3 = "<img src='templates/$template/images/misc/up.gif' border='0'>";}
		else{ $t3 = "<img src='templates/$template/images/misc/down.gif' border='0'>";}

		if($s == 1) $s = $sname1;
		if($s == 2) $s = $sname2;
		if($s == 3) $s = $sname3;
		if($s == 4) $s = $sname4;

		//-----------------------------------------------------------------
		//  Navigation Stuff
		//-----------------------------------------------------------------
		$rows_per_page = $config['nav_staff'];
		$numrows = $db->getInfo_countRows("staff");

		$lastpage = ceil($numrows/$rows_per_page);
		$p = (int)$p;

		if ($p < 1) $p = 1;
		elseif ($p > $lastpage) $p = $lastpage;

		if($numrows != FALSE) $limit = 'LIMIT ' .($p - 1) * $rows_per_page .',' .$rows_per_page;
		else $limit = NULL;

		//-----------------------------------------------------------------
		//  Load the staff table
		//-----------------------------------------------------------------

		$staff = $db->getTable("SELECT id, username, rank, active, email, live, intrests, programs, howlong, music, resources, age, comments FROM staff ORDER BY '$s' $t2 $limit");
		

		//-----------------------------------------------------------------
		//  Make a foreach to separate the results
		//-----------------------------------------------------------------

		foreach($staff as $idx=>$staff)
		{
			//-----------------------------------------------------------------
			//  Count for ID + trick
			//-----------------------------------------------------------------

			if($s == $sname1 && $t == "ASC")
				$idx_count = str_replace("-", "", $idx + (($p - 1) * $rows_per_page + 1) - $numrows - 1);
			else
				$idx_count = $idx + (($p - 1) * $rows_per_page + 1);
 

		$layout .= "<tr class='".row2color($idx)."' onMouseOver=this.className='con3' onMouseOut=this.className='".row2color($idx)."' onclick=window.location.href='$PHP_SELF?n=modules/staff&a=2&d={$staff['id']}'>
				<td align='center'>$idx_count</td>
				<td><a href='$PHP_SELF?n=modules/staff&a=2&d={$staff['id']}'>{$staff['username']}</a></td>
				<td>{$staff['rank']}</td>";
				if($staff['active'] == 0) { $layout .= "<td>No</td></tr>"; } else { $layout .= "<td>Yes</td></tr>"; }


			//-----------------------------------------------------------------
			//  Start from 1
			//-----------------------------------------------------------------

			$idx ++;
		}

		//-----------------------------------------------------------------
		//  Navigation Code
		//-----------------------------------------------------------------

		if ($p == 1) $nav_prev = "<tr><td class='con1' align='right'>&nbsp;</td>";
		else
		{
			$prevpage = $p-1;
			$nav_prev = "<tr><td class='con1' align='left'><a href='$PHP_SELF?n=modules/staff&s=$s&t=$t2&p=$prevpage'>&laquo; {$language['Staff previous']}</a></td>";
		}

		$nav_nr = '[ '.paginate($lastpage, $p, $PHP_SELF.'?n=modules/staff&s='.$s.'&t='.$t2).' ]';

		if($idx == $numrows) $nav_nr = NULL;

		if ($p == $lastpage)
			$nav_next = "<td class='con1' align='right'>&nbsp;</td></tr>";
		else
		{
			$nextcode = $numrows - $idx * $p;
			if($nextcode > $idx) $how_next = $idx;
			else $how_next = $nextcode;

			$nextpage = $p+1;

			$nav_next = "<td class='con1' align='right'><a href='$PHP_SELF?n=modules/staff&s=$s&t=$t2&p=$nextpage'>{$language['Staff next']} $how_next &raquo;</a></td></tr>";
		}

		if($idx == $numrows)
		{
			$nav_head = "class='con1'";
			$nav = NULL;
		}
		else
		{
			$nav_head = "class='head'";
			$nav = ''.$nav_prev.''.$nav_next.'';
		}

		//-----------------------------------------------------------------
		//  Start Layout
		//-----------------------------------------------------------------
	if($config['staffsetting'] == 0 ){
?>
		<table class='main' cellspacing='1' cellpadding='4'>
  		<tr class='head'>
  		<td class='head' colspan='2' align='center'><?= ($language['Staff Admin Title']) ?></td>
  		</tr>
		<tr><td class="con1">
		<?= ($language['Disabled Message']) ?>
		<br /></td></tr></table>
<?
}
else
{
?>
		<table class='main' cellspacing='1' cellpadding='4'>
  		<tr class='head'>
   		<td class='head' colspan='2'><?= ($language['Staff Title']) ?></td>
 		</tr>
		<tr>
    		<td style='Text-align:left;' class='con1' colspan='2'>
      		<table class='main' cellspacing='1' cellpadding='4'>
		<tr class='bottom'>
		<td align='center'><a href="<?= $PHP_SELF ?>?n=modules/staff&s=1&t=<?= $t ?>&p=<?= $p ?>"><? if($s == $sname1) echo $t3; else echo "#" ?></a></td>
		<td width="35%"><a href="<?= $PHP_SELF ?>?n=modules/staff&s=2&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Staff Name'] ?> <? if($s == $sname2) echo $t3 ?></a></td>
		<td width="35%"><a href="<?= $PHP_SELF ?>?n=modules/staff&s=3&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Staff Rank'] ?> <? if($s == $sname3) echo $t3 ?></a></td>
		<td width="27%"><a href="<?= $PHP_SELF ?>?n=modules/staff&s=4&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Staff Active'] ?> <? if($s == $sname4) echo $t3 ?></a></td></tr>
		<?= $layout ?>
		<tr>
		</table>
        	</td>
		</tr></table>
			<br />
			<table class="main" cellspacing="1" cellpadding="4" width="100%">
			<col width="50%"><col width="50%">
			<tr <?= $nav_head ?>>
			<td colspan="2">
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
			<col width="50%"><col width="50%">
			<tr class="empty">
			<td align="left"><?= $language['Staff nav'] ?> <b><?= $idx ?></b> <?= $language['Staff nav2'] ?> <b><?= $numrows ?></b></td>
			<td align="right"><?= $nav_nr ?></td>
			</tr>
			</table>
			</td>
			</tr>
			<?= $nav ?>
		</table>
<br />
<?
}
	break;

//-----------------------------------------------------------------
//  Admin Panel (Case 3:)
//-----------------------------------------------------------------
case 3:
if(isset($is_guest) || isset($is_user) || isset($is_moderator))
{header("location: $PHP_SELF?i=2"); exit; }
?>
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='head'>
   <td class='head' colspan='2' align='center'><?= ($language['Staff Overlook']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Admin Panel Navigation']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

	<tr class="con1"><td class="con1"><center><a href="?n=modules/admin">&raquo; Admin Panel &laquo;</a> ||<a href="?n=modules/staff&a=9"> &raquo; Add Staff &laquo;</a> ||<a href="?n=modules/staff&a=7"> &raquo; Manage Staff &laquo;</a> ||<a href="?n=modules/staff&a=11"> &raquo; Add Ranks &laquo;</a> ||<a href="?n=modules/staff&a=14"> &raquo; Manage Ranks &laquo;</a> </center></td></tr>
</table></table>
<br />
<br />
				<form method="post" action="<?= $PHP_SELF ?>?n=modules/staff&a=3">
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Staff Admin Title1']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

				<tr>
				<td class="con1">Enabled/Disabled</td>
				<td class="con1" width="65%"><?= form_dropdown('editstaffsetting', Array('0' => Array('0' => '0','1' => ''.$language['Staff Disabled'].''),'1' => Array('0' => '1','1' => ''.$language['Staff Enabled'].'')), $config['staffsetting'], "style='width:100%'", "class='box'", "") ?></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Staff Navigation:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($config['nav_staff']) ?>" name="editnavstaff" style="width:100%" maxlength="1000" class="box" tabindex="7"></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Manage Staff Navigation:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($config['nav_staff2']) ?>" name="editnavstaff2" style="width:100%" maxlength="1000" class="box" tabindex="7"></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Rank Navigation:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($config['rank_nav']) ?>" name="editranknav" style="width:100%" maxlength="1000" class="box" tabindex="7"></td>
				</tr>
				<tr>
				<td class="con1"><input type="button" style="width:100" class="box" value="Back" onClick="window.history.go(-1);" tabindex="19"></td>
				<td class="con1" align="right"><input type="submit" style="width:100" class="box" value="Add Staff" tabindex="18"></td>
				</tr>
				<input type="hidden" name="a" value="20">
</table></form></table>
<br />
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Staff Admin Title']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

	<tr class="con1"><td class="con1"><?= ($language['Information']) ?></td></tr>
</table></table>
</tr>
</table>
<?
	break;
//-----------------------------------------------------------------
//  Manage A Staff Member (Case 5:)
//-----------------------------------------------------------------

case 5:
if(isset($is_guest) || isset($is_user) || isset($is_moderator))
{header("location: $PHP_SELF?i=2"); exit; }

		$staff = $db->getLine("SELECT * FROM staff",$d);
?>
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='head'>
   <td class='head' colspan='2' align='center'><?= ($language['Staff Overlook']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Admin Panel Navigation']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>
	<tr class="con1"><td class="con1"><center><a href="?n=modules/admin">&raquo; Admin Panel &laquo;</a> ||<a href="?n=modules/staff&a=9"> &raquo; Add Staff &laquo;</a> ||<a href="?n=modules/staff&a=7"> &raquo; Manage Staff &laquo;</a> ||<a href="?n=modules/staff&a=11"> &raquo; Add Ranks &laquo;</a> ||<a href="?n=modules/staff&a=14"> &raquo; Manage Ranks &laquo;</a> </center></td></tr>
</table></table>
<br />
				<form method="post" action="<?= $PHP_SELF ?>?n=modules/staff">
				<table class="main" cellspacing="1" cellpadding="4" width="100%">
				<col width="40%"><col width="60%">
				<tr class="head"> 
				<td colspan="2" class="head">Manage A Staff Member</td>
				</tr>
				<tr class="bottom">
				<td height="21" colspan="2"><?= ($language['General Information']) ?></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Username:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['username']) ?>" name="editstaffusername" style="width:100%" maxlength="150" class="box" tabindex="5"></td>
				</tr>
				<tr>
				<? $ranks_db = $db->getTable("SELECT * FROM staff_positions"); ?>
				<td class="con1" valign="middle">Rank:</span></td>
				<td class="con1"><select name="editstaffrank" value="<?= ($staff['rank']) ?>" class="box" style="width:100%"><? foreach($ranks_db as $rank) echo "<option>{$rank['rank']}</option>" ?></select>
				</tr>
				<tr class="bottom">
				<td height="21" colspan="2"><?= ($language['Personal Information']) ?></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Email:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['email']) ?>" name="editstaffemail" style="width:100%" maxlength="150" class="box" tabindex="5"></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Current Age:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['age']) ?>" name="editstaffage" style="width:100%" maxlength="150" class="box" tabindex="6"></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Birthday:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['bday']) ?>" name="editstaffbday" style="width:100%" maxlength="1000" class="box" tabindex="7"></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Where do you live:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['live']) ?>" name="editstafflive" style="width:100%" maxlength="1000" class="box" tabindex="7"></td>
				</tr>
				<tr>
				<td class="con1" valign="top"><?= "{$language['Staff Intrest']}".dis_bb_em()."" ?></td>
				<td class="con1"><textarea style="width:100%; height:70px;" class="box" name="editstaffintrests"><?= $staff['intrests'] ?></textarea></td>
				</tr>
				<tr>
				<td class="con1" valign="top"><?= "{$language['Staff Programs']}".dis_bb_em()."" ?></td>
				<td class="con1"><textarea style="width:100%; height:70px;" class="box" name="editstaffprograms"><?= $staff['programs'] ?></textarea></td>
				</tr>
				<tr>
				<td class="con1" valign="top"><?= "{$language['Staff Programming']}".dis_bb_em()."" ?></td>
				<td class="con1"><textarea style="width:100%; height:70px;" class="box" name="editstaffprogramming"><?= $staff['programming'] ?></textarea></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">How long have you been doing this:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['howlong']) ?>" name="editstaffhowlong" style="width:100%" maxlength="1000" class="box" tabindex="7"></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Music Genre:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['music']) ?>" name="editstaffmusic" style="width:100%" maxlength="1000" class="box" tabindex="7"></td>
				</tr>
				<tr>
				<td class="con1" valign="top"><?= "{$language['Staff Resources']}".dis_bb_em()."" ?></td>
				<td class="con1"><textarea style="width:100%; height:70px;" class="box" name="editstaffresources"><?= $staff['resources'] ?></textarea></td>
				</tr>
				<tr>
				<td class="con1" valign="top"><?= "{$language['Staff WTGB']}".dis_bb_em()."" ?></td>
				<td class="con1"><textarea style="width:100%; height:70px;" class="box" name="editstaffwtgb"><?= $staff['wtgb'] ?></textarea></td>
				</tr>
				<tr>
				<td class="con1" valign="top"><?= "{$language['Staff Comments']}".dis_bb_em()."" ?></td>
				<td class="con1"><textarea style="width:100%; height:70px;" class="box" name="editstaffcomments"><?= $staff['comments'] ?></textarea></td>
				</tr>
				<tr class="bottom">
				<td height="21" colspan="2"><?=  ($language['Misc Information']) ?></td>
				</tr>
				<tr>
				<td class="con1">Active/Inactive</td>
				<td class="con1"><?= form_dropdown('editstaffactive', Array('0' => Array('0' => '0','1' => ''.$language['Staff No'].''),'1' => Array('0' => '1','1' => ''.$language['Staff Yes'].'')), $staff['active'], "style='width:100%'", "class='box'", "") ?></td>
				</tr>
				<tr>
				<td class="con1"><input type="button" style="width:100" class="box" value="Back" onClick="window.history.go(-1);" tabindex="19"></td>
				<td class="con1" align="right"><input type="submit" style="width:100" class="box" value="Edit Staff" tabindex="18"></td>
				</tr>
				<tr>
				<input type="hidden" name="a" value="1">
				<input type="hidden" name="d" value="<?= $staff['id'] ?>">
				</table></form>
</tr>
</table>
<?
	break;
	case 6:
if(isset($is_guest) || isset($is_user) || isset($is_moderator))
{header("location: $PHP_SELF?i=2"); exit; }

$id = $_GET['d']; // grabes the id
$staff = $db->getLine("SELECT * FROM staff WHERE id='$id'",$d); 
$delete = mysql_query("DELETE FROM staff WHERE id='$id'") or die(mysql_error());

?>
<?php
header("Location: $PHP_SELF?n=modules/staff&a=7");
?>

<?
	break;
	case 7:
if(isset($is_guest) || isset($is_user) || isset($is_moderator))
{header("location: $PHP_SELF?i=2"); exit; }
		//-----------------------------------------------------------------
		//  Sorting Stuff
		//-----------------------------------------------------------------

		if(!isset($s)) $s = 'id'; // Default value
		if(!isset($t)) $t = 'ASC'; // Default value

		$sname1 = "id";
		$sname2 = "username";
		$sname3 = "rank";
		$sname4 = "active";
		$sname5 = "delete";


		if($t == "ASC"){ $t = "DESC"; $t2 = "ASC"; }
		else{ $t = "ASC"; $t2 = "DESC"; }

		if($t == "ASC"){ $t3 = "<img src='templates/$template/images/misc/up.gif' border='0'>";}
		else{ $t3 = "<img src='templates/$template/images/misc/down.gif' border='0'>";}

		if($s == 1) $s = $sname1;
		if($s == 2) $s = $sname2;
		if($s == 3) $s = $sname3;
		if($s == 4) $s = $sname4;
		if($s == 5) $s = $sname5;

		//-----------------------------------------------------------------
		//  Navigation Stuff
		//-----------------------------------------------------------------
		$rows_per_page = $config['nav_staff2'];
		$numrows = $db->getInfo_countRows("staff");

		$lastpage = ceil($numrows/$rows_per_page);
		$p = (int)$p;

		if ($p < 1) $p = 1;
		elseif ($p > $lastpage) $p = $lastpage;

		if($numrows != FALSE) $limit = 'LIMIT ' .($p - 1) * $rows_per_page .',' .$rows_per_page;
		else $limit = NULL;

		//-----------------------------------------------------------------
		//  Load the staff table
		//-----------------------------------------------------------------

		$staff = $db->getTable("SELECT id, username, rank, active, email, live, intrests, programs, howlong, music, resources, age, comments FROM staff ORDER BY '$s' $t2 $limit");
		

		//-----------------------------------------------------------------
		//  Make a foreach to separate the results
		//-----------------------------------------------------------------

		foreach($staff as $idx=>$staff)
		{
			//-----------------------------------------------------------------
			//  Count for ID + trick
			//-----------------------------------------------------------------

			if($s == $sname1 && $t == "ASC")
				$idx_count = str_replace("-", "", $idx + (($p - 1) * $rows_per_page + 1) - $numrows - 1);
			else
				$idx_count = $idx + (($p - 1) * $rows_per_page + 1);
 

		$layout .= "<tr class='".row2color($idx)."' onMouseOver=this.className='con3' onMouseOut=this.className='".row2color($idx)."' onclick=window.location.href='$PHP_SELF?n=modules/staff&a=5&d={$staff['id']}'>
				<td align='center'>$idx_count</td>
				<td><a href='$PHP_SELF?n=modules/staff&a=5&d={$staff['id']}'>{$staff['username']}</a></td>
				<td>{$staff['rank']}</td>";
				if($staff['active'] == 0) { $layout .= "<td>No</td>"; } else { $layout .= "<td>Yes</td>"; }
         $layout .= "<td><a href='$PHP_SELF?n=modules/staff&a=15&d={$staff['id']}'>Delete</a></td></tr>";

			//-----------------------------------------------------------------
			//  Start from 1
			//-----------------------------------------------------------------

			$idx ++;
		}

		//-----------------------------------------------------------------
		//  Navigation Code
		//-----------------------------------------------------------------

		if ($p == 1) $nav_prev = "<tr><td class='con1' align='right'>&nbsp;</td>";
		else
		{
			$prevpage = $p-1;
			$nav_prev = "<tr><td class='con1' align='left'><a href='$PHP_SELF?n=modules/staff&a=14&s=$s&t=$t2&p=$prevpage'>&laquo; {$language['Staff previous']}</a></td>";
		}

		$nav_nr = '[ '.paginate($lastpage, $p, $PHP_SELF.'?n=modules/staff&a=14&s='.$s.'&t='.$t2).' ]';

		if($idx == $numrows) $nav_nr = NULL;

		if ($p == $lastpage)
			$nav_next = "<td class='con1' align='right'>&nbsp;</td></tr>";
		else
		{
			$nextcode = $numrows - $idx * $p;
			if($nextcode > $idx) $how_next = $idx;
			else $how_next = $nextcode;

			$nextpage = $p+1;

			$nav_next = "<td class='con1' align='right'><a href='$PHP_SELF?n=modules/staff&a=14&s=$s&t=$t2&p=$nextpage'>{$language['Staff next']} $how_next &raquo;</a></td></tr>";
		}

		if($idx == $numrows)
		{
			$nav_head = "class='con1'";
			$nav = NULL;
		}
		else
		{
			$nav_head = "class='head'";
			$nav = ''.$nav_prev.''.$nav_next.'';
		}

		//-----------------------------------------------------------------
		//  Start Layout
		//-----------------------------------------------------------------
?>
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='head'>
   <td class='head' colspan='2' align='center'><?= ($language['Staff Overlook']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Admin Panel Navigation']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

	<tr class="con1"><td class="con1"><center><a href="?n=modules/admin">&raquo; Admin Panel &laquo;</a> ||<a href="?n=modules/staff&a=9"> &raquo; Add Staff &laquo;</a> ||<a href="?n=modules/staff&a=7"> &raquo; Manage Staff &laquo;</a> ||<a href="?n=modules/staff&a=11"> &raquo; Add Ranks &laquo;</a> ||<a href="?n=modules/staff&a=14"> &raquo; Manage Ranks &laquo;</a> </center></td></tr>
</table></table>
<br />
		<table class='main' cellspacing='1' cellpadding='4'>
  		<tr class='head'>
   		<td class='head' colspan='2'><?= ($language['Staff Title']) ?></td>
 		</tr>
		<tr>
    		<td style='Text-align:left;' class='con1' colspan='2'>
      		<table class='main' cellspacing='1' cellpadding='4'>
		<tr class='bottom'>
		<td align='center'><a href="<?= $PHP_SELF ?>?n=modules/staff&a=7&s=1&t=<?= $t ?>&p=<?= $p ?>"><? if($s == $sname1) echo $t3; else echo "#" ?></a></td>
		<td width="35%"><a href="<?= $PHP_SELF ?>?n=modules/staff&a=7&s=2&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Staff Name'] ?> <? if($s == $sname2) echo $t3 ?></a></td>
		<td width="35%"><a href="<?= $PHP_SELF ?>?n=modules/staff&a=7&s=3&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Staff Rank'] ?> <? if($s == $sname3) echo $t3 ?></a></td>
		<td width="27%"><a href="<?= $PHP_SELF ?>?n=modules/staff&a=7&s=4&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Staff Active'] ?> <? if($s == $sname4) echo $t3 ?></a></td>
		<td><a href="<?= $PHP_SELF ?>?n=modules/staff&a=7&s=5&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Staff Delete'] ?> <? if($s == $sname5) echo $t3 ?></a></td></tr>
		<?= $layout ?>
		<tr>
		</table>
        	</td>
		</tr></table>
			<br />
			<table class="main" cellspacing="1" cellpadding="4" width="100%">
			<col width="50%"><col width="50%">
			<tr <?= $nav_head ?>>
			<td colspan="2">
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
			<col width="50%"><col width="50%">
			<tr class="empty">
			<td align="left"><?= $language['Staff nav'] ?> <b><?= $idx ?></b> <?= $language['Staff nav2'] ?> <b><?= $numrows ?></b></td>
			<td align="right"><?= $nav_nr ?></td>
			</tr>
			</table>
			</td>
			</tr>
			<?= $nav ?>
		</table></table>
<?
	break;
	case 8:
		//-----------------------------------------------------------------
		//  Begin writing the information for add staff.
		//-----------------------------------------------------------------
		$info['username'] = jcm_htmlspecialchars(jcm_stripslashes($editusername));
		$info['rank'] = $editrank;
		$info['description'] = $editrankdesc;
		$info['active'] = $editstatus;
		$db->insertRow("staff",$info);
		header("location: $PHP_SELF?n=modules/staff");
	break;

//-----------------------------------------------------------------
//  Add A Staff Member (Case 9:)
//-----------------------------------------------------------------
	case 9:
	if(isset($is_guest) || isset($is_user) || isset($is_moderator)) header("location: $PHP_SELF?i=2");
		$re = $db->getTable("SELECT id, username, rank, active, email, live, intrests, programs, howlong, music, resources, age, comments FROM staff");
?>
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='head'>
   <td class='head' colspan='2' align='center'><?= ($language['Staff Overlook']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Admin Panel Navigation']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>
	<tr class="con1"><td class="con1"><center><a href="?n=modules/admin">&raquo; Admin Panel &laquo;</a> ||<a href="?n=modules/staff&a=9"> &raquo; Add Staff &laquo;</a> ||<a href="?n=modules/staff&a=7"> &raquo; Manage Staff &laquo;</a> ||<a href="?n=modules/staff&a=11"> &raquo; Add Ranks &laquo;</a> ||<a href="?n=modules/staff&a=14"> &raquo; Manage Ranks &laquo;</a> </center></td></tr>
</table></table>
<br />
				<form method="post" action="<?= $PHP_SELF ?>?n=modules/staff">
				<table class="main" cellspacing="1" cellpadding="4" width="100%">
				<col width="40%"><col width="60%">
				<tr class="head"> 
				<td colspan="2" class="head"> Add A New Staff Member</td>
				</tr>
				<tr class="bottom">
				<td height="21" colspan="2">Staff Member Information</td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Username:</span></td>
				<td class="con1" valign="bottom"><input type="text" name="editusername" style="width:100%" maxlength="150" class="box" tabindex="5"></td>
				</tr>
				<tr>
				<? $ranks_db = $db->getTable("SELECT * FROM staff_positions"); ?>
				<td class="con1" valign="middle">Rank:</span></td>
				<td class="con1"><select name="editrank" class="box" style="width:100%"><? foreach($ranks_db as $rank) echo "<option>{$rank['rank']}</option>" ?></select>
				</tr>
	
				<tr>
				<td class="con1">Active/Inactive</td>
				<td class="con1"><?= @form_dropdown('editstatus', Array('0' => Array('0' => '0','1' => ''.$language['Staff No'].''),'1' => Array('0' => '1','1' => ''.$language['Staff Yes'].'')), $re['active'], "style='width:100%'", "class='box'", "") ?></td>
				</tr>
				<tr>
				<td class="con1"><input type="button" style="width:100" class="box" value="Back" onClick="window.history.go(-1);" tabindex="19"></td>
				<td class="con1" align="right"><input type="submit" style="width:100" class="box" value="Add Staff" tabindex="18"></td>
				</tr>
				<input type="hidden" name="a" value="8">
				</table></form></table>
<?
	break;
case 10:
		//-----------------------------------------------------------------
		//  Begin writing the information
		//-----------------------------------------------------------------
		$info['rank'] = $rank;
		$info['description'] = jcm_htmlspecialchars(jcm_stripslashes($rankdesc));
		$db->insertRow("staff_positions",$info);
		header("location: $PHP_SELF?n=modules/staff&a=14");
	break;

//-----------------------------------------------------------------
//  Add A Rank (Case 11:)
//-----------------------------------------------------------------
case 11:
if(isset($is_guest) || isset($is_user) || isset($is_moderator)) header("location: $PHP_SELF?i=2");
		$rank = $db->getTable("SELECT id,rank,description  FROM staff_postion");
		
?>
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='head'>
   <td class='head' colspan='2' align='center'><?= ($language['Staff Overlook']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Admin Panel Navigation']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>
	<tr class="con1"><td class="con1"><center><a href="?n=modules/admin">&raquo; Admin Panel &laquo;</a> ||<a href="?n=modules/staff&a=9"> &raquo; Add Staff &laquo;</a> ||<a href="?n=modules/staff&a=7"> &raquo; Manage Staff &laquo;</a> ||<a href="?n=modules/staff&a=11"> &raquo; Add Ranks &laquo;</a> ||<a href="?n=modules/staff&a=14"> &raquo; Manage Ranks &laquo;</a> </center></td></tr>
</table></table>
<br />
				<form method="post" action="<?= $PHP_SELF ?>?n=modules/staff&a=14">
				<table class="main" cellspacing="1" cellpadding="4" width="100%">
				<col width="40%"><col width="60%">
				<tr class="head"> 
				<td colspan="2" class="head">Add A New Rank</td>
				</tr>
				<tr class="bottom">
				<td height="21" colspan="2">Rank Information</td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Rank:</span></td>
				<td class="con1"><input type="text" name="rank" style="width:100%" maxlength="1000" class="box" tabindex="7">
				</tr>
				<tr>
				<td class="con1" valign="middle">Rank Description:</span></td>
				<td class="con1" valign="bottom"><input type="text" name="rankdesc" style="width:100%" maxlength="1000" class="box" tabindex="7"></td>
				</tr>
				<tr>
				<td class="con1"><input type="button" style="width:100" class="box" value="Back" onClick="window.history.go(-1);" tabindex="19"></td>
				<td class="con1" align="right"><input type="submit" style="width:100" class="box" value="Add Rank" tabindex="18"></td>
				</tr>
			<input type="hidden" name="a" value="10">
				</table></form></table>
<?
	break;
	case 12:
	if(isset($is_guest) || isset($is_user) || isset($is_moderator)) header("location: $PHP_SELF?i=2");
		$rank = $db->getLine("SELECT * FROM staff_positions",$d);
?>
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='head'>
   <td class='head' colspan='2' align='center'><?= ($language['Staff Overlook']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Admin Panel Navigation']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>
	<tr class="con1"><td class="con1"><center><a href="?n=modules/admin">&raquo; Admin Panel &laquo;</a> ||<a href="?n=modules/staff&a=9"> &raquo; Add Staff &laquo;</a> ||<a href="?n=modules/staff&a=7"> &raquo; Manage Staff &laquo;</a> ||<a href="?n=modules/staff&a=11"> &raquo; Add Ranks &laquo;</a> ||<a href="?n=modules/staff&a=14"> &raquo; Manage Ranks &laquo;</a> </center></td></tr>
</table></table>
<br />
				<form method="post" action="<?= $PHP_SELF ?>?n=modules/staff&a=14">
				<input type="hidden" name="id" value="<? $rank['id']; ?>">
				<table class="main" cellspacing="1" cellpadding="4" width="100%">
				<col width="20%"><col width="80%">
				<tr class="head"> 
				<td colspan="2" class="head">Edit Rank</td>
				</tr>
				<tr class="bottom">
				<td height="21" colspan="2">Rank Information</td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Rank:</span></td>
				<td class="con1"><input type="text" name="rank" style="width:100%" maxlength="1000" class="box" tabindex="7" value="<?= ($rank['rank']) ?>">
				</tr>
				<tr>
				<td class="con1" valign="middle">Rank Description:</span></td>
				<td class="con1"><textarea style="width:100%; height:55px;" class="box" name="rankdesc"><?= ($rank['description']) ?></textarea></td>
				</tr>
				<tr>
				<td class="con1"><input type="button" style="width:100" class="box" value="Back" onClick="window.history.go(-1);" tabindex="19"></td>
				<td class="con1" align="right"><input type="submit" style="width:100" class="box" value="Edit Rank" tabindex="18"></td>
				</tr>
				<input type="hidden" name="a" value="13">
			    <input type="hidden" name="d" value="<?= $rank['id'] ?>">
				</table></form></table>
<?
	break;
	case 13:
	if(isset($is_guest) || isset($is_user) || isset($is_moderator)) header("location: $PHP_SELF?i=2");
		//-----------------------------------------------------------------
		//  Begin writing the information
		//-----------------------------------------------------------------
		$info['rank'] = $rank;
		$info['description'] = jcm_htmlspecialchars(jcm_stripslashes($rankdesc));
		$db->updateRow("staff_positions",$info,"id= '$d'");
		header("location: $PHP_SELF?n=modules/staff&a=14");
	break;
	case 14:
// Manage staff ranks/postions


		//-----------------------------------------------------------------
		//  Sorting Stuff
		//-----------------------------------------------------------------

		if(!isset($s)) $s = 'id'; // Default value
		if(!isset($t)) $t = 'ASC'; // Default value

		$sname1 = "id";
		$sname2 = "rank";
		$sname3 = "description";
		$sname4 = "delete";


		if($t == "ASC"){ $t = "DESC"; $t2 = "ASC"; }
		else{ $t = "ASC"; $t2 = "DESC"; }

		if($t == "ASC"){ $t3 = "<img src='templates/$template/images/misc/up.gif' border='0'>";}
		else{ $t3 = "<img src='templates/$template/images/misc/down.gif' border='0'>";}

		if($s == 1) $s = $sname1;
		if($s == 2) $s = $sname2;
		if($s == 3) $s = $sname3;
		if($s == 4) $s = $sname4;


		//-----------------------------------------------------------------
		//  Navigation Stuff
		//-----------------------------------------------------------------
		$rows_per_page = $config['rank_nav'];
		$numrows = $db->getInfo_countRows("staff_positions");

		$lastpage = ceil($numrows/$rows_per_page);
		$p = (int)$p;

		if ($p < 1) $p = 1;
		elseif ($p > $lastpage) $p = $lastpage;

		if($numrows != FALSE) $limit = 'LIMIT ' .($p - 1) * $rows_per_page .',' .$rows_per_page;
		else $limit = NULL;

		//-----------------------------------------------------------------
		//  Load the staff table
		//-----------------------------------------------------------------

		$staff = $db->getTable("SELECT * FROM staff_positions ORDER BY '$s' $t2 $limit");
		

		//-----------------------------------------------------------------
		//  Make a foreach to separate the results
		//-----------------------------------------------------------------

		foreach($staff as $idx=>$staff)
		{
			//-----------------------------------------------------------------
			//  Count for ID + trick
			//-----------------------------------------------------------------

			if($s == $sname1 && $t == "ASC")
				$idx_count = str_replace("-", "", $idx + (($p - 1) * $rows_per_page + 1) - $numrows - 1);
			else
				$idx_count = $idx + (($p - 1) * $rows_per_page + 1);
 

		$layout .= "<tr class='".row2color($idx)."' onMouseOver=this.className='con3' onMouseOut=this.className='".row2color($idx)."' onclick=window.location.href='?n=modules/staff&a=12&d={$staff['id']}'>
				<td align='center'>$idx_count</td>
				<td><a href='?n=modules/staff&a=12&d={$staff['id']}'>{$staff['rank']}</a></td>
				<td>{$staff['description']}</td>
				<td><a href='$PHP_SELF?n=modules/staff&a=16&d={$staff['id']}'>Delete</a></td></tr>";


			//-----------------------------------------------------------------
			//  Start from 1
			//-----------------------------------------------------------------

			$idx ++;
		}

		//-----------------------------------------------------------------
		//  Navigation Code
		//-----------------------------------------------------------------

		if ($p == 1) $nav_prev = "<tr><td class='con1' align='right'>&nbsp;</td>";
		else
		{
			$prevpage = $p-1;
			$nav_prev = "<tr><td class='con1' align='left'><a href='$PHP_SELF?n=modules/staff&a=14&s=$s&t=$t2&p=$prevpage'>&laquo; {$language['Staff previous']}</a></td>";
		}

		$nav_nr = '[ '.paginate($lastpage, $p, $PHP_SELF.'?n=modules/staff&s='.$s.'&t='.$t2).' ]';

		if($idx == $numrows) $nav_nr = NULL;

		if ($p == $lastpage)
			$nav_next = "<td class='con1' align='right'>&nbsp;</td></tr>";
		else
		{
			$nextcode = $numrows - $idx * $p;
			if($nextcode > $idx) $how_next = $idx;
			else $how_next = $nextcode;

			$nextpage = $p+1;

			$nav_next = "<td class='con1' align='right'><a href='$PHP_SELF?n=modules/staff&a=14&s=$s&t=$t2&p=$nextpage'>{$language['Staff next']} $how_next &raquo;</a></td></tr>";
		}

		if($idx == $numrows)
		{
			$nav_head = "class='con1'";
			$nav = NULL;
		}
		else
		{
			$nav_head = "class='head'";
			$nav = ''.$nav_prev.''.$nav_next.'';
		}

		//-----------------------------------------------------------------
		//  Start Layout
		//-----------------------------------------------------------------
?>
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='head'>
   <td class='head' colspan='2' align='center'><?= ($language['Staff Overlook']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>

<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='bottom'>
   <td class='bottom' colspan='2' align='center'><?= ($language['Admin Panel Navigation']) ?></td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>
	<tr class="con1"><td class="con1"><center><a href="?n=modules/admin">&raquo; Admin Panel &laquo;</a> ||<a href="?n=modules/staff&a=9"> &raquo; Add Staff &laquo;</a> ||<a href="?n=modules/staff&a=7"> &raquo; Manage Staff &laquo;</a> ||<a href="?n=modules/staff&a=11"> &raquo; Add Ranks &laquo;</a> ||<a href="?n=modules/staff&a=14"> &raquo; Manage Ranks &laquo;</a> </center></td></tr>
</table></table>
<br />
		<table class='main' cellspacing='1' cellpadding='4'>
  		<tr class='head'>
   		<td class='head' colspan='2'><?= ($language['Rank Title']) ?></td>
 		</tr>
		<tr>
    		<td style='Text-align:left;' class='con1' colspan='2'>
      		<table class='main' cellspacing='1' cellpadding='4'>
		<tr class='bottom'>
		<td align='center'><a href="<?= $PHP_SELF ?>?n=modules/staff&a=14&s=1&t=<?= $t ?>&p=<?= $p ?>"><? if($s == $sname1) echo $t3; else echo "#" ?></a></td>
		<td width="35%"><a href="<?= $PHP_SELF ?>?n=modules/staff&a=14&s=2&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Rank Name'] ?> <? if($s == $sname2) echo $t3 ?></a></td>
		<td width="60%"><a href="<?= $PHP_SELF ?>?n=modules/staff&a=14&s=3&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Rank Description'] ?> <? if($s == $sname3) echo $t3 ?></a></td>
		<td width="10%"><a href="<?= $PHP_SELF ?>?n=modules/staff&a=14&s=4&t=<?= $t ?>&p=<?= $p ?>"><?= $language['Staff Delete'] ?> <? if($s == $sname4) echo $t3 ?></a></td></tr>
		<?= $layout ?>
		<tr>
		</table>
        	</td>
		</tr></table>
			<br />
			<table class="main" cellspacing="1" cellpadding="4" width="100%">
			<col width="50%"><col width="50%">
			<tr <?= $nav_head ?>>
			<td colspan="2">
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
			<col width="50%"><col width="50%">
			<tr class="empty">
			<td align="left"><?= $language['Rank nav'] ?> <b><?= $idx ?></b> <?= $language['Rank nav2'] ?> <b><?= $numrows ?></b></td>
			<td align="right"><?= $nav_nr ?></td>
			</tr>
			</table>
			</td>
			</tr>
			<?= $nav ?>
		</table></table>

<?
	break;
		case 15:
		//-----------------------------------------------------------------
		//  Begin writing the information
		//-----------------------------------------------------------------
if(isset($is_guest) || isset($is_user) || isset($is_moderator))
{header("location: $PHP_SELF?i=2"); exit; }
		$db->deleteRow("staff","id = '$d'");
		header("location: $PHP_SELF?n=modules/staff&a=7");
	break;
			case 16:
		//-----------------------------------------------------------------
		//  Begin writing the information
		//-----------------------------------------------------------------
if(isset($is_guest) || isset($is_user) || isset($is_moderator))
{header("location: $PHP_SELF?i=2"); exit; }
		$db->deleteRow("staff_positions","id = '$d'");
		header("location: $PHP_SELF?n=modules/staff&a=14");
	break;
		case 17:
		//-----------------------------------------------------------------
		//  Begin writing the information
		//-----------------------------------------------------------------
if(isset($is_guest) || isset($is_user) || isset($is_moderator))
{header("location: $PHP_SELF?i=2"); exit; }
		$db->deleteRow("staff","id = '$d'");
		header("location: $PHP_SELF?n=modules/staff");
	break;
		case 18:
		$staff = $db->getLine("SELECT * FROM staff",$d);
 $user = $db->getLine("SELECT * FROM users WHERE id='{$_SESSION['id']}' AND username='{$_SESSION['username']}'");
 if($staff['username'] == ($user['username'])) {
?>
<table class='main' cellspacing='1' cellpadding='4'>
  <tr class='head'>
   <td class='head' colspan='2' align='center'>Edit Staff Memeber</td>

  </tr>
<tr>
    <td style='Text-align:left;' class='con1' colspan='2'>
      <table class='main' cellspacing='1' cellpadding='4'>
				<form method="post" action="<?= $PHP_SELF ?>?n=modules/staff">
				<table class="main" cellspacing="1" cellpadding="4" width="100%">
				<col width="40%"><col width="60%">
				<tr class="head"> 
				<td colspan="2" class="head">Manage A Staff Member</td>
				</tr>
				<tr class="bottom">
				<td height="21" colspan="2"><?= ($language['General Information']) ?></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Username:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['username']) ?>" name="editstaffusername" style="width:100%" maxlength="150" class="box" tabindex="5"></td>
				</tr>
				<tr class="bottom">
				<td height="21" colspan="2"><?= ($language['Personal Information']) ?></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Email:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['email']) ?>" name="editstaffemail" style="width:100%" maxlength="150" class="box" tabindex="5"></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Current Age:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['age']) ?>" name="editstaffage" style="width:100%" maxlength="150" class="box" tabindex="6"></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Birthday:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['bday']) ?>" name="editstaffbday" style="width:100%" maxlength="1000" class="box" tabindex="7"></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Where do you live:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['live']) ?>" name="editstafflive" style="width:100%" maxlength="1000" class="box" tabindex="7"></td>
				</tr>
				<tr>
				<td class="con1" valign="top"><?= "{$language['Staff Intrest']}".dis_bb_em()."" ?></td>
				<td class="con1"><textarea style="width:100%; height:70px;" class="box" name="editstaffintrests"><?= $staff['intrests'] ?></textarea></td>
				</tr>
				<tr>
				<td class="con1" valign="top"><?= "{$language['Staff Programs']}".dis_bb_em()."" ?></td>
				<td class="con1"><textarea style="width:100%; height:70px;" class="box" name="editstaffprograms"><?= $staff['programs'] ?></textarea></td>
				</tr>
				<tr>
				<td class="con1" valign="top"><?= "{$language['Staff Programming']}".dis_bb_em()."" ?></td>
				<td class="con1"><textarea style="width:100%; height:70px;" class="box" name="editstaffprogramming"><?= $staff['programming'] ?></textarea></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">How long have you been doing this:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['howlong']) ?>" name="editstaffhowlong" style="width:100%" maxlength="1000" class="box" tabindex="7"></td>
				</tr>
				<tr>
				<td class="con1" valign="middle">Music Genre:</span></td>
				<td class="con1" valign="bottom"><input type="text" value="<?= ($staff['music']) ?>" name="editstaffmusic" style="width:100%" maxlength="1000" class="box" tabindex="7"></td>
				</tr>
				<tr>
				<td class="con1" valign="top"><?= "{$language['Staff Resources']}".dis_bb_em()."" ?></td>
				<td class="con1"><textarea style="width:100%; height:70px;" class="box" name="editstaffresources"><?= $staff['resources'] ?></textarea></td>
				</tr>
				<tr>
				<td class="con1" valign="top"><?= "{$language['Staff WTGB']}".dis_bb_em()."" ?></td>
				<td class="con1"><textarea style="width:100%; height:70px;" class="box" name="editstaffwtgb"><?= $staff['wtgb'] ?></textarea></td>
				</tr>
				<tr>
				<td class="con1" valign="top"><?= "{$language['Staff Comments']}".dis_bb_em()."" ?></td>
				<td class="con1"><textarea style="width:100%; height:70px;" class="box" name="editstaffcomments"><?= $staff['comments'] ?></textarea></td>
				</tr>
				<tr class="bottom">
				<td height="21" colspan="2"><?=  ($language['Misc Information']) ?></td>
				</tr>
				<tr>
				<td class="con1">Active/Inactive</td>
				<td class="con1"><?= form_dropdown('editstaffactive', Array('0' => Array('0' => '0','1' => ''.$language['Staff No'].''),'1' => Array('0' => '1','1' => ''.$language['Staff Yes'].'')), $staff['active'], "style='width:100%'", "class='box'", "") ?></td>
				</tr>
				<tr>
				<td class="con1"><input type="button" style="width:100" class="box" value="Back" onClick="window.history.go(-1);" tabindex="19"></td>
				<td class="con1" align="right"><input type="submit" style="width:100" class="box" value="Edit Staff" tabindex="18"></td>
				</tr>
				<tr>
				<input type="hidden" name="a" value="19">
				<input type="hidden" name="d" value="<?= $staff['id'] ?>">
				</table></form>
</tr>
</table>
<?
}
else
{header("location: $PHP_SELF?i=2"); exit; }
	break;

case 19:

		//-----------------------------------------------------------------
		//  BBcode check
		//-----------------------------------------------------------------

		for ($i = 1; $i <= 5; $i++)
		{
			if(check_tag_order($editstaffintrests) == $i) { header("location: $PHP_SELF?n=modules/staff&i=9$i"); exit; }
			if(check_tag_order($editstaffprograms) == $i) { header("location: $PHP_SELF?n=modules/staff&i=9$i"); exit; }
			if(check_tag_order($editstaffprogramming) == $i) { header("location: $PHP_SELF?n=modules/staff&i=9$i"); exit; }
			if(check_tag_order($editstaffresources) == $i) { header("location: $PHP_SELF?n=modules/staff&i=9$i"); exit; }
			if(check_tag_order($editstaffwtgb) == $i) { header("location: $PHP_SELF?n=modules/staff&i=9$i"); exit; }
			if(check_tag_order($editstaffcomments) == $i) { header("location: $PHP_SELF?n=modules/staff&i=9$i"); exit; }
		}
		
		
		//-----------------------------------------------------------------
		//  Take care of some things
		//-----------------------------------------------------------------

		$editstaffintrests = jcm_linebreaks(trim(jcm_stripslashes($editstaffintrests)));
		$editstaffprograms = jcm_linebreaks(trim(jcm_stripslashes($editstaffprograms)));
		$editstaffprogramming = jcm_linebreaks(trim(jcm_stripslashes($editstaffprogramming)));
		$editstaffresources = jcm_linebreaks(trim(jcm_stripslashes($editstaffresources)));
		$editstaffwtgb = jcm_linebreaks(trim(jcm_stripslashes($editstaffwtgb)));
		$editstaffcomments = jcm_linebreaks(trim(jcm_stripslashes($editstaffcomments)));
		if($overflow = check_tag_order($editstaffintrests)) $editstaffintrests = substr($editstaffintrests, 0, $overflow[0]).substr($editstaffintrests, $overflow[1], (strlen($editstaffintrests) - $overflow[0]));
		if($overflow = check_tag_order($editstaffprograms)) $editstaffprograms = substr($editstaffprograms, 0, $overflow[0]).substr($editstaffprograms, $overflow[1], (strlen($editstaffprograms) - $overflow[0]));
		if($overflow = check_tag_order($editstaffprogramming)) $editstaffprogramming = substr($editstaffprogramming, 0, $overflow[0]).substr($editstaffprogramming, $overflow[1], (strlen($editstaffprogramming) - $overflow[0]));
		if($overflow = check_tag_order($editstaffresources)) $editstaffresources = substr($editstaffresources, 0, $overflow[0]).substr($editstaffresources, $overflow[1], (strlen($editstaffresources) - $overflow[0]));
		if($overflow = check_tag_order($editstaffwtgb)) $editstaffwtgb = substr($editstaffwtgb, 0, $overflow[0]).substr($editstaffwtgb, $overflow[1], (strlen($editstaffwtgb) - $overflow[0]));
		if($overflow = check_tag_order($editstaffcomments)) $editstaffcomments = substr($editstaffcomments, 0, $overflow[0]).substr($editstaffcomments, $overflow[1], (strlen($editstaffcomments) - $overflow[0]));

		//-----------------------------------------------------------------
		//  Begin writing the information
		//-----------------------------------------------------------------
		$edit['username'] = jcm_htmlspecialchars(jcm_stripslashes($editstaffusername));
		$edit['email'] = $editstaffemail;
		$edit['age'] = $editstaffage;
		$edit['bday'] = $editstaffbday;
		$edit['live'] = $editstafflive;
		$edit['intrests'] = $editstaffintrests;
		$edit['programs'] = $editstaffprograms;
		$edit['programming'] = $editstaffprogramming;
		$edit['howlong'] = $editstaffhowlong;
		$edit['music'] = $editstaffmusic;
		$edit['resources'] = $editstaffresources;
		$edit['wtgb'] = $editstaffwtgb;
		$edit['comments'] = $editstaffcomments;
		$db->updateRow("staff",$edit,"id= '$d'");
		header("location: $PHP_SELF?n=modules/staff");
	break;
case 20:
		//-----------------------------------------------------------------
		//  Begin writing the information
		//-----------------------------------------------------------------
		$cfg['staffsetting'] = $editstaffsetting;
		$cfg['nav_staff'] = $editnavstaff;
		$cfg['nav_staff2'] = $editnavstaff2;
		$cfg['rank_nav'] = $editranknav;

		while (list($key, $input) = @each($cfg)) if ($config[$key] != $input) $db->updateRow("config",array('value' => ''.$input.''),"variable = '$key'");
		header("location: $PHP_SELF?n=modules/staff&a=3");
break;
}
?>